package com.bz.xtcx.manager.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.bz.xtcx.manager.entity.LibImage;

public interface LibImageMapper {
    
    @Insert("insert into `lib_image`(lib_id, field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, status, creater)"
            + " VALUES(#{libId, jdbcType=VARCHAR},"
            + " #{field1, jdbcType=VARCHAR},"
            + " #{field2, jdbcType=VARCHAR},"
            + " #{field3, jdbcType=VARCHAR},"
            + " #{field4, jdbcType=VARCHAR},"
            + " #{field5, jdbcType=VARCHAR},"
            + " #{field6, jdbcType=VARCHAR},"
            + " #{field7, jdbcType=VARCHAR},"
            + " #{field8, jdbcType=VARCHAR},"
            + " #{field9, jdbcType=VARCHAR},"
            + " #{field10, jdbcType=VARCHAR},"
            + " #{status, jdbcType=INTEGER},"
            + " #{creater, jdbcType=VARCHAR})"
            )
    @Options(useGeneratedKeys = true, keyProperty = "id")  
    int insert(LibImage e);
    
    @Delete("delete from `lib_image` where id = #{id}")
    int del(int id);
    
    @Update("update `lib_image` set lib_id=#{libId, jdbcType=VARCHAR},"
            + " field1=#{field1, jdbcType=VARCHAR},"
            + " field2=#{field2, jdbcType=VARCHAR},"
            + " field3=#{field3, jdbcType=VARCHAR},"
            + " field4=#{field4, jdbcType=VARCHAR},"
            + " field5=#{field5, jdbcType=VARCHAR},"
            + " field6=#{field6, jdbcType=VARCHAR},"
            + " field7=#{field7, jdbcType=VARCHAR},"
            + " field8=#{field8, jdbcType=VARCHAR},"
            + " field9=#{field9, jdbcType=VARCHAR},"
            + " field10=#{field10, jdbcType=VARCHAR},"
            + " status=#{status, jdbcType=INTEGER}"
            + " where id=#{id}")
    int update(LibImage e);
    
    
    @Select("select * from `lib_image` where lib_id = #{libId, jdbcType=VARCHAR}")
    @Results(
            id = "busUserImage",
            value = {
                @Result(id = true, property = "id", column = "id"),
                @Result(property = "libId", column = "lib_id"),
                @Result(property = "field1", column = "field1"),
                @Result(property = "field2", column = "field2"),
                @Result(property = "field3", column = "field3"),
                @Result(property = "field4", column = "field4"),
                @Result(property = "field5", column = "field5"),
                @Result(property = "field6", column = "field6"),
                @Result(property = "field7", column = "field7"),
                @Result(property = "field8", column = "field8"),
                @Result(property = "field9", column = "field9"),
                @Result(property = "field10", column = "field10"),
                @Result(property = "status", column = "status"),
                @Result(property = "creater", column = "creater"),
                @Result(property = "createTime", column = "create_time"),
                @Result(property = "updater", column = "updater"),
                @Result(property = "updateTime", column = "update_time")
            }
        )
    LibImage findByLibId(String libId);
    
    @Select("select field1 from `lib_image` where lib_id = #{libId, jdbcType=VARCHAR}")
    String findLogoByLibId(String libId);
}
